<?php 
/*****************************************************************************
 * SV-Cart 促销详细页
 *===========================================================================
 * 版权所有上海实玮网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.seevia.cn
 *---------------------------------------------------------------------------
 *这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
 *不允许对程序代码以任何形式任何目的的再发布。
 *===========================================================================
 * $开发: 上海实玮$
 * $Id: view.ctp 4433 2009-09-22 10:08:09Z huangbo $
*****************************************************************************/
?>
<div id="Products_box"><?php echo $this->element('ur_here', array('cache'=>'+0 hour'));?>
<h1 class="headers"><span class="l"></span><span class="r"></span><b><?php echo $promotion['PromotionI18n']['title']; ?></b></h1>
        <div class="Edit_box">
  <div id="article_info">
    
  <p class="note article_title">
  <div id="user_msg">
  	<p class="article_time">
  	  <span class="title">&nbsp;<?php echo $promotion['Promotion']['start_time']." - ".$promotion['Promotion']['end_time']; ?></span></p><br />
    <p class="article">
    	<span>
    		<?php echo $promotion['PromotionI18n']['meta_description']; ?>
    	</span>
    </p>
  </div>
  <div id="select_article"> <p><?php if($neighbours['next']){ ?>
 <?php echo $this->data['languages']['next'].$this->data['languages']['piece'];?>: 
  <?php echo $html->link("{$neighbours['next']['PromotionI18n']['title']}","{$neighbours['next']['Promotion']['id']}",array(),false,false); } ?>
<br />
 <?php if($neighbours['prev']){?>
 <?php echo $this->data['languages']['previous'].$this->data['languages']['piece'];?>: 
 <?php echo $html->link("{$neighbours['prev']['PromotionI18n']['title']}","{$neighbours['prev']['Promotion']['id']}",array(),false,false); } ?>
</p></div> </div>
</div><!--文章列表End-->
<!--相关商品-->
<?php if(isset($this->data['cache_products']) && sizeof($this->data['cache_products'])>0){?>
<div class="Edit_box">
	<div class="Edit_info" style="padding-bottom:0;">
	<div class="head"><strong><?php echo $this->data['languages']['correlative_products'];?></strong></div>
    <div class="Item_List" style="border:none;">
	<ul style="margin:0;">
	<cake:nocache>
	<?php 
		foreach($this->data['cache_products'] as $key=>$v){
			if(isset($v['ProductI18n'])){
			if($v['Product']['img_thumb'] == ""){
				if($this->data['configs']['products_default_image'] == ""){
					$v['Product']['img_thumb'] = "/img/product_default.jpg";
				}else{
					$v['Product']['img_thumb'] = $this->data['configs']['products_default_image'];
				}
			}			
			echo $html->tag('li',$html->para('pic',
				 $html->link(
				 $html->image("{$v['Product']['img_thumb']}",array('width'=>'108','height'=>'108','alt'=>$v['ProductI18n']['name']))
				 ,$svshow->sku_product_link($v['Product']['id'],$v['ProductI18n']['name'],$v['Product']['code'],$this->data['configs']['product_link_type']),'',false,false)
				 ,array(),false)
				 .$html->para('info',
				 $html->tag('span',$html->link("{$v['ProductI18n']['name']}",$svshow->sku_product_link($v['Product']['id'],$v['ProductI18n']['name'],$v['Product']['code'],$this->data['configs']['product_link_type']),array("target"=>"_blank"),false,false),'name')
				 .$html->tag('span',$html->tag('font',
				 	 (isset($this->data['configs']['currencies_setting']) && $this->data['configs']['currencies_setting'] == 1 && $session->check('currencies') && $session->check('Config.locale') && isset($this->data['currencies'][$session->read('currencies')]))?$svshow->price_format($v['Product']['shop_price']*$this->data['currencies'][$session->read('currencies')][$session->read('Config.locale')]['Currency']['rate'],$this->data['currencies'][$session->read('currencies')][$session->read('Config.locale')]['Currency']['format']):$svshow->price_format($v['Product']['shop_price'],$this->data['configs']['price_format'])
				 	 ,array('color'=>'#F9630C')),'Price')		 		
				 ,array(),false),array('style'=>'padding:0;'));		
		}		
	}?>
	</cake:nocache>
</ul>
</div>
</div>
</div>
<!--相关商品End-->
<?php } ?>    		
</div>
<?php echo $this->element('news', array('cache'=>array('time'=> "+0 hour",'key'=>'news'.$template_style)));?>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<script>
var div = document.getElementById('Edit_info');
var commentSuccess = function(o){
	    try{   
	    	var result = YAHOO.lang.JSON.parse(o.responseText);  
		}catch (e){   
			alert("Invalid data");
			YAHOO.example.container.wait.hide();
		} 
		div.innerHTML += '<div id="user_msg"><p class="msg_title"><span class="title">'+comment+'： '+result.name+' <font color="#A7A9A8">'+waitting_for_check+'</font></span></p><p class="msg_txt"><span>'+result.content+'</span></p></div> ';
		};

var commentFailure = function(o){
 	alert("Failure");
};

var commentback =
{
  success:commentSuccess,
  failure:commentFailure,
  argument:{}
};
function submitComment(frm){
  var cmt = new Object;
  cmt.username        = frm.elements['username'].value;
  cmt.user_id        = frm.elements['user_id'].value;
  cmt.email           = frm.elements['email'].value;
  cmt.content         = frm.elements['content'].value;
  cmt.type            = frm.elements['cmt_type'].value;
  cmt.id              = frm.elements['id'].value;
 // cmt.enabled_captcha = frm.elements['enabled_captcha'] ? frm.elements['enabled_captcha'].value : '0';
 // cmt.captcha         = frm.elements['captcha'] ? frm.elements['captcha'].value : '';
  cmt.rank            = 0;

  for (i = 0; i < frm.elements['comment_rank'].length; i++)
  {
    if (frm.elements['comment_rank'][i].checked)
    {
       cmt.rank = frm.elements['comment_rank'][i].value;
     }
  }
//  if (cmt.username.length == 0)
//  {
//     alert(cmt_empty_username);
//     return false;
//  }

  if (cmt.email.length > 0)
  {
     if (cmt.email.length<5)
     {
        alert('cmt_error_email');
        return false;
      }
   }
   else
   {
        alert('cmt_empty_email');
        return false;
   }

   if (cmt.content.length == 0)
   {
      alert('cmt_empty_content');
      return false;
   }

 //  if (cmt.enabled_captcha > 0 && cmt.captcha.length == 0 )
 //  {
 //     alert('captcha_not_null');
 //     return false;
 //  }
	
	
	var sUrl = "/commons/add_comment/";
	//alert(document.getElementById('user_name').innerHTML);
	var postData ='cmt='+YAHOO.lang.JSON.stringify(cmt);
	postData+='&username='+cmt.username+'&user_id='+cmt.user_id+"&email="+cmt.email+"&content="+cmt.content+"&type="+cmt.type+"&id="+cmt.id+"&rank="+cmt.rank;
//	alert(sUrl+postData);
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, commentback,postData);
	frm.reset();
}

</script>